package com.example.stuwork.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 作业分配实体类
 * 对应 assignment_allocation 表
 */
public class AssignmentAllocation implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 分配ID
     */
    private Long allocationId;

    /**
     * 作业ID
     */
    private Long assignmentId;

    /**
     * 学生学号
     */
    private String studentId;

    /**
     * 状态：0-未提交，1-已提交未批改，2-已批改，3-已超时
     */
    private Integer status;

    /**
     * 最新提交ID
     */
    private Long submissionId;

    /**
     * 批改分数
     */
    private Integer score;

    /**
     * 分配时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date allocatedAt;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 非表字段：作业信息
     */
    private Assignment assignment;

    /**
     * 非表字段：学生信息
     */
    private Student student;

    /**
     * 无参构造函数
     */
    public AssignmentAllocation() {
    }

    /**
     * 全参构造函数
     */
    public AssignmentAllocation(Long allocationId, Long assignmentId, String studentId, Integer status,
                              Long submissionId, Integer score, Date createTime, Date updateTime) {
        this.allocationId = allocationId;
        this.assignmentId = assignmentId;
        this.studentId = studentId;
        this.status = status;
        this.submissionId = submissionId;
        this.score = score;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    /**
     * 用于创建作业分配的构造函数
     */
    public AssignmentAllocation(Long assignmentId, String studentId) {
        this.assignmentId = assignmentId;
        this.studentId = studentId;
        this.status = 0; // 默认未提交
        this.allocatedAt = new Date(); // 设置分配时间为当前时间
    }

    // Getters and Setters
    public Long getAllocationId() {
        return allocationId;
    }

    public void setAllocationId(Long allocationId) {
        this.allocationId = allocationId;
    }

    public Long getAssignmentId() {
        return assignmentId;
    }

    public void setAssignmentId(Long assignmentId) {
        this.assignmentId = assignmentId;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Long getSubmissionId() {
        return submissionId;
    }

    public void setSubmissionId(Long submissionId) {
        this.submissionId = submissionId;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public Date getAllocatedAt() {
        return allocatedAt;
    }

    public void setAllocatedAt(Date allocatedAt) {
        this.allocatedAt = allocatedAt;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Assignment getAssignment() {
        return assignment;
    }

    public void setAssignment(Assignment assignment) {
        this.assignment = assignment;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    @Override
    public String toString() {
        return "AssignmentAllocation{" +
                "allocationId=" + allocationId +
                ", assignmentId=" + assignmentId +
                ", studentId='" + studentId + '\'' +
                ", status=" + status +
                ", submissionId=" + submissionId +
                ", score=" + score +
                ", allocatedAt=" + allocatedAt +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
} 